Finally, Standards!

Standard ECMA-262 promises to tidy up the differences between JavaScript and JScript! Does it?
Since this was first written, ECMA has produced a second edition of their 262 document for JavaScript. Not much has changed in the standard, and the third release, which was due sometime late in 1999, promised to be more interesting. (It was approved in December of 1999, but has not been published yet at the ECMA website.) Other developments pertinent to Web scripting have occurred, and we'll note them in the following text, in this color and typeface.

Discussion

In June, 1997, the ECMA (European Computer Manufacturers Association) General Assembly adopted a standard for a "general purpose scripting language" called ECMAScript, also known as Standard ECMA-262. You and we are more likely to call it "JavaScript." At first reading, the ECMA standard follows the path laid out by Netscape for JavaScript in in every fundamental respect (which leaves IE 3.x JScript somewhat lacking; some critics have labeled ECMA-262 a "rubberstamping" of Netscape's JavaScript specification). JavaScript code written for Netscape Communicator 4.0x should run without incident or surprises on an ECMAScript-compliant browser.

ECMA-262 lays out a standard, but leaves room for what we'll call "differences of opinion" among browser manufacturers as to what constitutes a conformant browser. Here is item 2 from the standard:

2 Conformance

That's a mouthful, isn't it? It seems to us that this dilutes the standard somewhat, since it means that any given browser manufacturer can still add all sorts of new "gee-whiz" features to its version of JavaScript, and effectively deny you any real use of those features on the broad Web because you can't depend on all the possible end-users having the browser version supporting those features. In other words, just knowing that the browser is "ECMA-262 compliant" isn't enough.

Still, it's a start. The 1999 3rd release of the standard should tie up a few loose ends.

Microsoft has publicly promised to comply with the standard beginning with Internet Explorer 4.0. The launch of IE 4.0 has proved that promise to be kept in the broadest sense, although it's hard to tell since Netscape has added features in Communicator that don't appear to be in IE. Perhaps because of this Microsoft now claims that Communicator's JavaScript engine isn't EMCA-262 compliant! Not surprisingly, Netscape disagrees, at least with respect to Communicator 4.7.

The ECMA-262 specification lays out fundamental aspects of the language, but shies away from browser environment issues. It doesn't address, for example, what interface a compliant engine might be expected to handle. At first this seems to a grave omission, because it's user events which are the most interesting and dynamic part of scripting. The HTML 4.0 specification published by the W3 Consortium (W3C) is silent on the topic as well, so that leaves us as developers in limbo as to what events we can expect an ECMA-262 compliant browser to handle.

Luckily, the W3C has created a specification for a browser Document Object Model (DOM). This specification details how the browser organizes page elements, and what scriptable elements and events each element supports. As of summer 1999, Internet Explorer 5.0 fully supports the DOM (although some say that support has a few bugs in it), and only the coming Mozilla/Gecko/Navigator 5.0 release of the Netscape (now iPlanet?) browser product will fully support the DOM. (If, in fact, it's ever released. We have our doubts.)

One more interesting omission involves the do...while() looping construct, which is not mentioned in ECMA-262, but supported by Netscape Communicator. As much as you might want to use it, you'll probably be better off with a simple while() loop. No longer true with the release of Internet Explorer 5.0.

Conclusion: as of the time we write this, you're still in the business of worrying about what browser is "at the other end." The ECMA-262 initiative is a good start, however, toward the day when you can get out of that business and just concentrate on writing good and useful scripts for your Web pages. In the meantime, if you write scripts that use only ECMA-262 compliant language constructs and objects, and only use events found in Netscape Navigator 3.2 (believe it or not, they're still out there) and later (even if the audience is Internet Explorer 4.0 or 5.0), the maximum number of users possible should be able to enjoy your JavaScripted web pages.

You will probably be safe using JavaScript/JScript as supported in either major 4.x release; since both major browsers are now free to the public, there's no strong reason (in our ever-humble opinion) to tie yourself down to only that which was supported in the 3.x releases. Internet Explorer, in its 4.x and 5.x revisions, has a practical stranglehold on the market, so you can pretty much assume that you've taken care of just about everybody if you write fully IE-compatible script.

Copyright ©2000 by Charles River Media, All Rights Reserved